package devstar_cloud_provider

import (
	"code.gitea.io/gitea/modules/setting"
	devstar_cloud_provider_errors "code.gitea.io/gitea/services/devstar_cloud_provider/errors"
	devstar_cloud_provider_tencent_nat "code.gitea.io/gitea/services/devstar_cloud_provider/tencent/nat_port_mapping"
)

// CreateNATRulePort 抽象接口，创建 NAT 端口映射规则
func CreateNATRulePort(privatePort, publicPort uint64, description string) error {

	if setting.Devstar.Cloud.Enabled == false {
		return devstar_cloud_provider_errors.ErrCloudNATProviderDisabled{}
	}

	// 根据配置文件指定云服务厂商创建 NAT Rule
	switch setting.Devstar.Cloud.Provider {
	case setting.CLOUD_PROVIDER_TENCENT:
		// 指定腾讯云执行 NAT 端口创建
		return devstar_cloud_provider_tencent_nat.AssignDevstarCloudNATPortForwarding2TencentCloud(privatePort, publicPort, description)
	}

	return nil
}
